

//
//  ShopingCartView.m
//  ChineseCollegeStudentsNetwork
//
//  Created by 鹿达令 on 2019/3/23.
//  Copyright © 2019年 刘喆. All rights reserved.
//

#import "ShopingCartView.h"

@implementation ShopingCartView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self addSubview:self.jianButton];
        [self addSubview:self.numberTextField];
        [self addSubview:self.jiaButton];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    [_jianButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left);
        make.height.equalTo(@20);
        make.width.equalTo(@20);
        make.top.equalTo(self.mas_top);
    }];
    
    [_jiaButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right);
        make.height.equalTo(@20);
        make.width.equalTo(@20);
        make.top.equalTo(self.mas_top);
    }];
    
    [_numberTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.jianButton.mas_right);
        make.right.equalTo(self.jiaButton.mas_left);
        make.height.equalTo(@20);
        make.top.equalTo(self.mas_top);
    }];
}
- (UIButton *)jianButton {
    if (!_jianButton) {
        _jianButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _jianButton.layer.borderColor = [UIColor lightGrayColor].CGColor;
        _jianButton.layer.borderWidth = .5f;
        [_jianButton setTitle:@"-" forState:UIControlStateNormal];
        [_jianButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
        _jianButton.titleLabel.font = [UIFont systemFontOfSize:13];
        
    }
    return _jianButton;
}

- (UIButton *)jiaButton {
    if (!_jiaButton) {
        _jiaButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _jiaButton.layer.borderColor = [UIColor lightGrayColor].CGColor;
        _jiaButton.layer.borderWidth = .5f;
        [_jiaButton setTitle:@"+" forState:UIControlStateNormal];
        [_jiaButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        _jiaButton.titleLabel.font = [UIFont systemFontOfSize:13];
    }
    return _jiaButton;
}

- (UITextField *)numberTextField {
    if (!_numberTextField) {
        _numberTextField = [[UITextField alloc]init];
        _numberTextField.textColor = [UIColor blackColor];
        _numberTextField.textAlignment = NSTextAlignmentCenter;
        _numberTextField.font = [UIFont systemFontOfSize:13];
    }
    return _numberTextField;
}

@end
